package com.tangjiali.collections;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Solution {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        Collections.addAll(list,2,3,4,5,4,3,1);
        System.out.println(list);       //[2, 3, 4, 5, 4, 3, 1]
        System.out.println("-------------打乱顺序--------------");
        Collections.shuffle(list);
        System.out.println(list);       //[4, 3, 1, 4, 3, 2, 5]
        System.out.println("-------------升序--------------");
        Collections.sort(list);
        System.out.println(list);       //[1, 2, 3, 3, 4, 4, 5]
        System.out.println("-------------降序--------------");
        Collections.sort(list,(a,b)->b-a);
        System.out.println(list);       //[5, 4, 4, 3, 3, 2, 1]
    }
}
